import { useStore } from '@renderer/store/useStore'
import { useEffect } from 'react'
import { Alert } from 'antd'

function Error() {
  const error = useStore((state) => state.error)
  const setError = useStore((state) => state.setError)
  useEffect(() => {
    const timer = setTimeout(() => setError(''), 2000)
    return () => clearTimeout(timer)
  }, [])
  if (!error) return <></>
  return (
    <>
      <main className="absolute top-0 z-10 w-full">
        <Alert message={error} type="info" showIcon></Alert>
      </main>
    </>
  )
}
export default Error
